package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.service.IHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@RestController
@RequestMapping("shopping")
public class HomePageController {

    @Autowired
    private IHomeService homeService;

    @GetMapping("homepage")
    public ResponseData<List<PanelDto>> home() {
        Set<PanelDto> dtoSet = homeService.homepage();
        return new ResponseUtil<List<PanelDto>>().setData(new ArrayList<>(dtoSet));
    }

}
